#include"stack.h"
#include<stdlib.h>
typedef struct {
	ST s1;
	ST s2;
}myqueue,*pmyqueue;
pmyqueue myqueuecreate()
{
	pmyqueue obj = (pmyqueue)malloc(sizeof(myqueue));
	if (obj == NULL)
	{
		perror("malloc");
		return -1;
	}
	STinit(&obj->s1);
	STinit(&obj->s2);
	return obj;
}
int myqueuepeek(pmyqueue obj)
{
	if (STempty(&obj->s2))
	{
		while (!STempty(&obj->s1))
		{
			int top = STtop(&obj->s1);
			STpush(&obj->s2, top);
			STpop(&obj->s1);
		}
	}
	return STtop(&obj->s2);
}
void myqueuepush(pmyqueue obj, int x)
{
	STpush(&obj->s1, x);
}
int myqueuepop(pmyqueue obj)
{
	int front = myqueuepeek(obj);
	STpop(&obj->s2);
	return front;
}
bool myqueueempty(pmyqueue obj)
{
	return STempty(&obj->s1) && STempty(&obj->s2);
}
void myqueuefree(pmyqueue obj)
{
	STdestroy(&obj->s1);
	STdestroy(&obj->s2);
	free(obj);
}